package com.hh.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hh.dao.UsersMapper;
import com.hh.entity.Users;
import com.hh.service.UserService;
@Service
public class UserServiceImpl implements UserService {
	@Autowired
	UsersMapper userDao;
	
	@Override
	public void transfer(int fromId, int toId, int money) {
		Users a=userDao.selectByPrimaryKey(fromId);
		Users b=userDao.selectByPrimaryKey(toId);
		
		a.setMoney(a.getMoney()-money);
		//int m=10/0;
		b.setMoney(b.getMoney()+money);

		userDao.updateByPrimaryKeySelective(a);
		userDao.updateByPrimaryKeySelective(b);
	}

}
